
var Edge = function(obj) {
	this.class = 'Edge';
	obj = obj || {};
	
	this.id = obj.id || "";
	this.left = obj.left || "";
	this.height = obj.height || "";
	
	return this;
};

Edge.prototype.toXML = function() {
	var xml = '<addEdgeRequest id="' + this.id + '" left="'
	+ this.left + '" right="' + (this.left*1 + 1) + '" height="' + this.height + '"/>';
	
	return xml;
};

Edge.prototype.fromXML = function(xml) {
	// <addEdgeRequest id="alkj3ksjd" left="3" right="4" height="137"/>
	xml = xml.replace(/\r\n|\n/g, ''); // remove line breaks
	
	var idMatch = xml.match(/id="(\S+)"/i) || [];
	this.id = idMatch[1] || "";
	
	var leftMatch = xml.match(/left="(\d+)"/i) || [];
	this.left = leftMatch[1] || 0;
	
	var heightMatch = xml.match(/height="(\d+)"/i) || [];
	this.height = heightMatch[1] || 0;
	
	return this;
};

module.exports = Edge;
